import React from 'react'
import { Divider, Modal, Form, Input } from 'antd'
import LwjTable from 'components/LwjTable/LwjTable'
import DescriptionList from 'components/DescriptionList';
import { LwjSowPicList } from 'components'

const List = ({
  global,
  currentItem,
  auditType,
  onModify,
  modifyVisible,
  dispatch,
  onDelete,
  deleteVisible,
  showDelete,
  update,
  form: { getFieldDecorator, validateFields },
  ...tableProps,
})=> {
  const { Description } = DescriptionList;
  const confirm = Modal.confirm
  const FormItem = Form.Item;
  const formItemLayout = {
    labelCol: {
      xs: { span: 4 },
      sm: { span: 4 },
    },
    wrapperCol: {
      xs: { span: 20 },
      sm: { span: 20 },
    },
  };
  const columns = [
    {
      title: '商品库名称',
      dataIndex: 'name',
      key: 'name',

    },
    {
      title: '来源门店',
      dataIndex: 'salesDistributorName',
      key: 'salesDistributorName',

    },
    {
      title: '操作',
      key: 'handle',
      render: (text, record) => (
        <span>
          <a onClick={() => onModify(record)} >修改名称</a>
          <Divider type="vertical" />
          <a onClick={() => update(record) } >编辑</a>
          <Divider type="vertical" />
          <a onClick={() => onDelete(record)} >删除</a>
        </span>
      )
    }
  ];

  return(
    <div>
    <Modal visible={modifyVisible}
        title={"修改名称"}
        confirmLoading={global}
        destroyOnClose={true}
        onOk={() => {
          validateFields((err, values) => {
            if (err) {
              return;
            }
            else {
              dispatch({
                type: 'commodityBank/modify',
                payload: {
                  storeId: currentItem.id,
                  values: values
                }
              })
              dispatch({
                type: 'commodityBank/setModifyVisible',
                payload: false
              })
            }
          });
        }}
        onCancel={() => dispatch({
          type: 'commodityBank/setModifyVisible', payload: false
        })}>
        <Form>
          <FormItem label="商品库名称:" {...formItemLayout}>
            {getFieldDecorator('name', {
              rules: [{ required: true, message: '请输入新商品库名称' }],
            })(<Input type="textarea" placeholder="请输入新商品库名称" />)}
          </FormItem>
        </Form>
      </Modal>

      <LwjTable
        {...tableProps}
        dispatch={dispatch}
        columns={columns} />
    </div>
  )
}
export default Form.create()(List)
